Skip to content

Conversation

@sayantn
Copy link
Contributor

@sayantn sayantn commented Oct 9, 2025

Split off from #147520 with just this change for easier review

r? @RalfJung

@rustbot
Copy link
Collaborator

rustbot commented Oct 9, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 9, 2025
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow review, and thanks!

Please also add tests. All new code should always come with tests. :) Testing this in const-eval is enough since Miri uses the same implementation.

View changes since this review

}
let inv_shift_bits = (elem_size_bits - shift_bits) as u32;

let result_bits = if is_left {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a comment explaining why this logic, executed on u128, correctly implements the semantics for all integer types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added a comment, could you check if its enough

@sayantn
Copy link
Contributor Author

sayantn commented Nov 3, 2025

We can't test in const-eval yet right? This doesn't make the intrinsics const. So we have to test in Miri

@RalfJung
Copy link
Member

RalfJung commented Nov 3, 2025

Oh right, this has the impl in rustc but doesn't expose it yet as that is blocked or more extensive testing... yeah a Miri test also works.

@bors
Copy link
Collaborator

bors commented Nov 3, 2025

☔ The latest upstream changes (presumably #148446) made this pull request unmergeable. Please resolve the merge conflicts.

@sayantn
Copy link
Contributor Author

sayantn commented Nov 3, 2025

Also @RalfJung , #147521 has been blocked for quite some time. Should I reroll??

@sayantn sayantn force-pushed the simd-funnel-shifts branch from 3947340 to b3afd22 Compare November 3, 2025 23:10
@rustbot
Copy link
Collaborator

rustbot commented Nov 3, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rustbot

This comment has been minimized.

@RalfJung
Copy link
Member

RalfJung commented Nov 4, 2025

Those tests check that we find the UB; please also add tests ensuring we return the correct result (including the corner case shift_bits == 0).

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited the comment a little. You didn't talk about the implementation doing << and >> and | at all! You were supposed to explain why those are the right operations to use. Imagine explaining this to someone who has never seen a funnel shift before in their life (i.e., someone like me).

But even with all that, I still don't get it. You basically say "because they live in the lower bits, the implementation is easy". That explains nothing, it just asserts without justification that it is easy. What is the argument for why the bits end up in the right place?

View changes since this review

@bors
Copy link
Collaborator

bors commented Nov 5, 2025

☔ The latest upstream changes (presumably #148507) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 5, 2025

Since there's more work happening in this direction, what are your thoughts on adding a to/from array conversion for all simd types via a trait and adding that trait bound to the intrinsic? Then the intrinsic body could be written in library code and work for all backends that do not implement the simd intrinsics (#93145)

@RalfJung
Copy link
Member

RalfJung commented Nov 5, 2025

Yeah if we could have fallback impls for the simd_* intrinsics that'd be great.

@sayantn sayantn force-pushed the simd-funnel-shifts branch from b3afd22 to 87bd458 Compare November 5, 2025 21:33
@rustbot
Copy link
Collaborator

rustbot commented Nov 5, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@RalfJung RalfJung added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2025
@sayantn sayantn force-pushed the simd-funnel-shifts branch from 87bd458 to b767368 Compare November 5, 2025 23:48
@sayantn sayantn force-pushed the simd-funnel-shifts branch from b767368 to 50a6df4 Compare November 6, 2025 00:00
@sayantn
Copy link
Contributor Author

sayantn commented Nov 6, 2025

I have added a lot more explanation, could you check if that is enough?

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants